//
//  FLLPresentFirstTableViewCell.m
//  FLLGodOfCooking
//
//  Created by LL.F on 16/9/7.
//  Copyright © 2016年 LL.F. All rights reserved.
//

#import "FLLPresentFirstTableViewCell.h"
#import "FLLMacro.h"
#import "FLLPresentFirstCollectionViewCell.h"
#import "UIImageView+WebCache.h"
#import "PresentShequ_Talent.h"
//#import "FLLPresentModel.h"
//#import "PresentBanner.h"
//#import "PresentData.h"
//#import "PresentSecData.h"
//#import "PresentShequ_Marrow.h"
//#import "PresentShequ_Topics.h"

@interface FLLPresentFirstTableViewCell ()<UICollectionViewDelegateFlowLayout, UICollectionViewDelegate, UICollectionViewDataSource>

@end
@implementation FLLPresentFirstTableViewCell

- (void)awakeFromNib {
    // Initialization code
    [self createPresentCollectionView];
}
- (void)createPresentCollectionView
{
    _presentFirstLayout.minimumInteritemSpacing = 0;
    _presentFirstLayout.minimumLineSpacing = 0;
    _presentFirstLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    _presentFirstLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    _presentFirstCollectionView.delegate = self;
    _presentFirstCollectionView.dataSource = self;
    _presentFirstCollectionView.showsHorizontalScrollIndicator = NO;
    _presentFirstCollectionView.backgroundColor = [UIColor whiteColor];
    [_presentFirstCollectionView registerNib:[UINib nibWithNibName:@"FLLPresentFirstCollectionViewCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"presentFirstCollectionCell"];
    
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    
    return _array.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    FLLPresentFirstCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"presentFirstCollectionCell" forIndexPath:indexPath];
    [cell.userImageView sd_setImageWithURL:[NSURL URLWithString:_array[indexPath.row].head_img] placeholderImage:[UIImage new] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
    }];
    cell.userNameLabel.text = _array[indexPath.row].nick;
    cell.userNameLabel.font = [UIFont systemFontOfSize:14 * kWidthScale];
    cell.fansCount.text = [NSString stringWithFormat:@"粉丝:%ld", (long)_array[indexPath.row].tongji_be_follow];
    cell.fansCount.font = [UIFont systemFontOfSize:12 * kWidthScale];
    
    return cell;
    
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CGFloat itemWidth = _presentFirstCollectionView.bounds.size.width / 4.5 ;
    CGFloat itemHeight = _presentFirstCollectionView.bounds.size.height ;
    return CGSizeMake(itemWidth, itemHeight);
}
- (void)setArray:(NSArray *)array
{

    _array = array;
    [self.presentFirstCollectionView reloadData];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
